'use strict';
const bcrypt = require('bcryptjs');

module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
  const Ap = app.model.define(
    'ap',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
        category_id: INTEGER(11),
        course_id: INTEGER(11),
        teacher_id: INTEGER(11),
        student_id: INTEGER(11),
        course_student_id: INTEGER(11),
        score: INTEGER(11),
        desc: STRING(255),
    },
    {
      tableName: 'ap',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: false, // 不想要 updatedAt
      createdAt: 'created_at', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );
    Ap.associate = () => {
        const { Student, Course,Teacher } = app.model;
        Ap.hasOne(Student, {foreignKey: 'id', sourceKey: 'student_id'})
        Ap.hasOne(Course, {foreignKey: 'id', sourceKey: 'course_id'})
        Ap.hasOne(Teacher, {foreignKey: 'id', sourceKey: 'teacher_id'})
    };
  return Ap;
};
